<template>
  <div class="totast alert show" v-show="isShow">
    <div>{{message}}456{{isShow}}</div>
  </div>
</template>

<script>
export default {
  name:'Toast',
  data() {
    return {
      message: "123",
      isShow: false
    };
  },
  methods: {
    show(message = "默认文字", durtion = 2000) {
      this.isShow = true;
      this.message = message;
      setTimeout(() => {
        this.isShow = false;
        this.message = "";
      }, durtion);
    }
  }
};
</script>

<style>
.totast{
  
}
.alert {
  transform: translate(-50%, -100%);
  left: 50%;
  top: 50%;
  position: fixed;
  text-align: center;
  margin: auto;
  background-color: red;
  color:#fff
}
</style>